



/*
--------------------------------------------------------------------------------------------------------
The following code is to replicate all results in Tables A2- A16 (in Appendix) in Rodrigue et al. (2022)
--------------------------------------------------------------------------------------------------------
1. lnso2: firm-level emission intensity of so2;
2. lndust: firm-level emission intensity of industrial dust;
3. Abatement_so2: firm-level abatement in so2;
4. Abatement_dust: firm-level abatement in dust;
5. lnKL: firm-level capital to labor ratio
6. Tariff: tariff
7. lnso2_ini: initial level of so2 emission intensity;
8. lndust_ini: initial level of dust emission intensity;
9. tariff_prod: initial tariff* initial-producivity
10. ventilation: ventilation coefficients for each province in each year;
11. ventilation_prod: ventilation coefficient * initial productivity
12. cic: 4-digit industry classification 
13. prov: province
14. ownership: SOE (ownerships==1|ownerships==2); private (ownerships==3); foreign (ownerships==4|ownerships==5);
15. cic_year, prov_year, owner_year: industry-year, province-year and ownership-year dummies. 
16. exp_tfp: interaction of firm-level export status and TFP
19. abt_so2_exp: interaction of firm-level abatement and export status
20. lnso2_d; lndust_d, tfp_acf_new_d, etc: denote the first difference variables at firm-level 
21. lnvintage: capital vintage
22. NRG: firm-level energe usage
23. Imp_NRG: firm-level imported energe
24. Imp_abt: imported abatement equipment
25. Mix: export product mix
26. Demand: the meausre of cross-country measure of demand for clean production

*/







************************************     Table A2    *******************************************
************************************     Table A2    *******************************************
************************************     Table A2    *******************************************

*-----------------------------------------------------------------------------
*Table A2 in The appendix: The first stage results
*----------------------------------------------------------------------------



use "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp",clear
rename exp_dummy2 Export
rename so2_new2 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod

*----------------------------------------------------------------------
* the following codes genrate columns 1-4 in (1) and (2) of Table A2

 *--------------------------------------------------
 *SO2: Colomns 1 and 2 of Table A2 
 *-------------------------------------------------
ivreghdfe lnso2  (Export Abatement_so2= ventilation tariff_prod )   Productivity Tariff,   a(cic prov year ownership) cluster (prov_c) first

 *--------------------------------------------------
 *SO2: Colomns 3 and 4 of Table A2 
 *-------------------------------------------------
ivreghdfe lnso2  (Export Abatement_so2=ventilation tariff_prod)   Productivity Tariff lnKL lnso2_ini,   a(cic prov year ownership) cluster (prov_c) first

 *--------------------------------------------------
 *Dust: Colomns 1 and 2 of Table A2 
 *-------------------------------------------------
ivreghdfe lndust  (Export Abatement_dust=ventilation tariff_prod )   Productivity Tariff,   a(cic prov year ownership) cluster (prov_c) first

 *--------------------------------------------------
 *Dust: Colomns 3 and 4 of Table A2 
 *-------------------------------------------------
ivreghdfe lndust  (Export Abatement_dust=ventilation tariff_prod )   Productivity Tariff lnKL lndust_ini,   a(cic prov year ownership) cluster (prov_c) first





*-------------------------------------------------------------------------------------------------
*----------------------------------------------------------------------
* the following codes genrate columns 5-8 in (3) and (4) of Table A2

use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp2",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod




 capture drop ub
 egen ub=pctile(lndust),p(97)

 *--------------------------------------------------
 *SO2: Colomns 5 and 6 of Table A2 
 *-------------------------------------------------
 ivreghdfe lnso2  (Export Abatement_so2=Ventilation tariff_prod   )  ///
 Productivity Tariff lnKL , a(indc year) cluster (prov_c) first

 *--------------------------------------------
 *dust: Colomns 5 and 6 of Table A2 
 *------------------------------------------------
 ivreghdfe lndust  (Export Abatement_dust=Ventilation tariff_prod   )  ///
 Productivity Tariff lnKL , a(indc year) cluster (prov_c) first



****************************************************************
 use   "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp2",clear
*drop Productivity Tariff lnKL Abatement_so2 Abatement_dust Export
* *************************************************
*gen exp_dummy_d=exp_dummy2-exp_dummy2_lag
rename exp_dummy2 Export
rename so2_new1_d Abatement_so2
rename dust_new1_d Abatement_dust
rename tfp_acf_new_d Productivity
rename lntariff_d Tariff
rename lnkl_d lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod


 *--------------------------------------------------
 *SO2: Colomns 7 and 8 of Table A2 
 *-------------------------------------------------
ivreghdfe lnso2_d  (Export Abatement_so2= Ventilation tariff_prod  )   Productivity Tariff lnKL, ///
 a(cic prov year ownership  lndust_ini) cluster (prov_c) first
 
  *--------------------------------------------
 *dust: Colomns 7 and 8 of Table A2 
 *------------------------------------------------
ivreghdfe lndust_d  (Export Abatement_dust= Ventilation tariff_prod  )  Productivity Tariff lnKL  , ///
 a(cic prov year ownership lndust_ini )  cluster (prov_c) first
***************************************************************************************************************************













************************************     Table A3 (A13)   *******************************************
************************************     Table A3 (A13)   *******************************************
************************************     Table A3 (A13)   *******************************************

 *------------------------------------------------------------------------------------------------
 * Table A3 in the Appendix: trimmed outliers (first stage for Table A13)
 *------------------------------------------------------------------------------------------------
 

*---------------------------------------------------------------------------------
* For Columns 1-2 and 5-6: control for province, year, ownership and ownership FE
*----------------------------------------------------------------------------------
use "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod

capture drop ub_dust
egen ub_so2=pctile(lnso2), p(99)
egen lb_so2=pctile(lnso2),p(1)

egen ub_dust=pctile(lndust),p(99)
egen lb_dust=pctile(lndust),p(1)



*------------------------------------------------------
*3.1 for SO2: column 1-2 in A3 (column 1-4 for so2 in A13)
*------------------------------------------------------
ivreghdfe lnso2  (Export Abatement_so2= ventilation ventilation_prod tariff_prod)   Productivity Tariff if lnso2<ub_so2&lnso2>lb_so2,   a(cic prov year ownership) cluster (prov_c) first

ivreghdfe lnso2  (Export Abatement_so2= ventilation ventilation_prod tariff_prod)   Productivity Tariff lnKL lnso2_ini if lnso2<ub_so2&lnso2>lb_so2,   a(cic prov year ownership) cluster (prov_c) first

*----------------------------------------------------------
*3.2 for dust: column 5-6 in A3 (column 1-4 for dust in A13)
*----------------------------------------------------------
ivreghdfe lndust  (Export Abatement_dust= ventilation ventilation_prod tariff_prod)   Productivity Tariff if lndust<ub_dust&lndust>lb_dust, a(cic prov year ownership) cluster (prov_c) first

ivreghdfe lndust  (Export Abatement_dust= ventilation ventilation_prod tariff_prod)   Productivity Tariff lnKL lndust_ini if lndust<ub_dust&lndust>lb_dust, a(cic prov year ownership) cluster (prov_c) first

/*
* compute R2
predict y_hat, xb
egen y_bar=mean(lnso2)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lnso2-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
drop y_hat y_bar diff1 diff2 SSR SST R2
*/


***********************************************************************************************


*---------------------------------------------------------------------------------
* For Columns 3-4 and 7-8: control for firm and year FE and first-difference 
*----------------------------------------------------------------------------------
use "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp2",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod

capture drop ub_dust
egen ub_so2=pctile(lnso2), p(99)
egen lb_so2=pctile(lnso2),p(1)

egen ub_dust=pctile(lndust),p(99)
egen lb_dust=pctile(lndust),p(1)





*-------------------------------------------------------------------------------
*3.3 column 3 and 7 in A3 (column 5-6 for so2 in A13 and columns 5-6 in A13 for dust)
*----------------------------------------------------------------------------------

 ivreghdfe lnso2  (Export Abatement_so2= ventilation ventilation_prod tariff_prod)  ///
 Productivity Tariff lnKL if lnso2<ub_so2&lnso2>lb_so2, a(indc year)  cluster(prov_c) first


 ivreghdfe lndust  (Export Abatement_dust= ventilation ventilation_prod tariff_prod)  ///
 Productivity Tariff lnKL if lndust<ub_dust&lndust>lb_dust, a(indc  year)  cluster(prov_c) first

 /*
* compute R2
predict y_hat, xb
egen y_bar=mean(lnso2_d)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lnso2_d-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
drop y_hat y_bar diff1 diff2 SSR SST R2
*/

* *****************************************
 
use "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp2",clear
rename exp_dummy2 Export
rename so2_new1_d Abatement_so2
rename dust_new1_d Abatement_dust
rename tfp_acf_new_d Productivity
rename lntariff_d Tariff
rename lnkl_d lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod


capture drop ub_dust
egen ub_so2=pctile(lnso2), p(99)
egen lb_so2=pctile(lnso2),p(1)

egen ub_dust=pctile(lndust),p(99)
egen lb_dust=pctile(lndust),p(1)





*---------------------------------------------------------------------------------------
*3.4  column 4-8 in the A3 (column 7-8 for so2 in A13 and columns 7-8 in A13 for dust)
*----------------------------------------------------------------------------------------
ivreghdfe lnso2_d  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod)   Productivity Tariff lnKL if lnso2<ub_so2&lnso2>lb_so2, a(cic prov year ownership) cluster(prov_c)  first


ivreghdfe lndust_d  (Export Abatement_dust= ventilation ventilation_prod tariff_prod)  ///
Productivity Tariff lnKL if lndust<ub_dust&lndust>lb_dust, a(cic prov year ownership) cluster(prov_c) first


***************************************************************************************************************************












************************************     Table A4 (A14)   *******************************************
************************************     Table A4 (A14)   *******************************************
************************************     Table A4 (A14)   *******************************************


 *----------------------------------------------------------
 * Table A4: exclude year 2004 (first stage for table A14)
 *--------------------------------------------------------
 
 
*---------------------------------------------------------------------------------
* For Columns 1-2 and 5-6: control for province, year, ownership and ownership FE
*---------------------------------------------------------------------------------- 


use "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod

capture drop ub_dust
egen ub_dust=pctile(lndust),p(97)




*---------------------------
*4.1 for SO2: column 1-2 in A4
*---------------------------
ivreghdfe lnso2  (Export Abatement_so2= ventilation ventilation_prod tariff_prod)   Productivity Tariff if year!=2004,   a(cic prov year ownership) cluster (prov_c) first

ivreghdfe lnso2  (Export Abatement_so2= ventilation ventilation_prod tariff_prod)   Productivity Tariff lnKL lnso2_ini if  year!=2004,   a(cic prov year ownership) cluster (prov_c) first

*-------------------------------
*4.2 for dust: column 5-6 in A4
*-------------------------------
ivreghdfe lndust  (Export Abatement_dust= ventilation ventilation_prod tariff_prod)   Productivity Tariff if year!=2004, a(cic prov year ownership) cluster (prov_c) first

ivreghdfe lndust  (Export Abatement_dust= ventilation ventilation_prod tariff_prod)   Productivity Tariff lnKL lndust_ini if  year!=2004, a(cic prov year ownership) cluster (prov_c) first

/*
* compute R2
predict y_hat, xb
egen y_bar=mean(lndust)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lndust-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
*/


**********************************

*---------------------------------------------------------------------------------
* For Columns 3-4 and 7-8: control for firm and year FE and first-difference 
*----------------------------------------------------------------------------------

use "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp2",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod

capture drop ub_dust
egen ub_so2=pctile(lnso2), p(99)
egen lb_so2=pctile(lnso2),p(1)

egen ub_dust=pctile(lndust),p(99)
egen lb_dust=pctile(lndust),p(1)





*---------------------------
*4.3 column 3 and 7 in A4
*---------------------------

 ivreghdfe lnso2  (Export Abatement_so2= ventilation ventilation_prod tariff_prod)  ///
 Productivity Tariff lnKL if year!=2004, a(indc year)  cluster(prov_c) first


 ivreghdfe lndust  (Export Abatement_dust= ventilation ventilation_prod tariff_prod)  ///
 Productivity Tariff lnKL if  year!=2004, a(indc  year)  cluster(prov_c) first

 /*
* compute R2
predict y_hat, xb
egen y_bar=mean(lndust_d)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lndust_d-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
*/

* *****************************************
 
use "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp2",clear
rename exp_dummy2 Export
rename so2_new1_d Abatement_so2
rename dust_new1_d Abatement_dust
rename tfp_acf_new_d Productivity
rename lntariff_d Tariff
rename lnkl_d lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod






*-------------------------------
*4.4  column 4 and 8 in the A4
*--------------------------------
ivreghdfe lnso2_d  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod)   Productivity Tariff lnKL  if year!=2004, a(cic prov year ownership) cluster(prov_c) first


ivreghdfe lndust_d  (Export Abatement_dust= ventilation ventilation_prod tariff_prod)  ///
Productivity Tariff lnKL if  year!=2004, a(cic prov year ownership) cluster(prov_c) first


***************************************************************************************************************************


 
 
 




 
 



************************************     Table A5    *******************************************
************************************     Table A5    *******************************************
************************************     Table A5    *******************************************



 

 *---------------------------------------------------------------------------------
* For Columns 1-2 and 5-6: control for province, year, ownership and ownership FE
*---------------------------------------------------------------------------------- 

use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod



replace Export= Export*1 if year==1999
replace Export= Export*1.3255 if year==2000
replace Export= Export*1.3882 if year==2001
replace Export= Export*1.6325 if year==2002
replace Export= Export*1.5373 if year==2003
replace Export= Export*2.3255 if year==2004
replace Export= Export*2.7373 if year==2005

*---------------------------------------
* 5.1 columns 1-2 of Table A5
*-----------------------------------------
ivreghdfe lnso2  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation)   Productivity Tariff, a(cic prov year ownership) cluster (prov_c)

ivreghdfe lnso2  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation)   Productivity Tariff lnKL lnso2_ini, a(cic prov year ownership) cluster (prov_c)


*---------------------------------------
* 5.2 columns 5-6 of Table A5
*-----------------------------------------
ivreghdfe lndust  (Export Abatement_dust=  tariff_prod ventilation_prod  ventilation)   Productivity Tariff  , a(cic prov year ownership) cluster (prov_c)

ivreghdfe lndust  (Export Abatement_dust=  tariff_prod ventilation_prod  ventilation)   Productivity Tariff lnKL lndust_ini , a(cic prov year ownership) cluster (prov_c)


/*
* compute R2
predict y_hat, xb
egen y_bar=mean(lndust)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lndust-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
*/



*----------------------

*---------------------------------------------------------------------------------
* For Columns 3-4 and 7-8: control for firm and year FE and first-difference 
*----------------------------------------------------------------------------------

use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp2",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod


replace Export= Export*1 if year==1999
replace Export= Export*1.3255 if year==2000
replace Export= Export*1.3882 if year==2001
replace Export= Export*1.6325 if year==2002
replace Export= Export*1.5373 if year==2003
replace Export= Export*2.3255 if year==2004
replace Export= Export*2.7373 if year==2005
 capture drop ub

 egen ub=pctile(lndust),p(97)

*---------------------------------------
* 5.3 columns 3 and 7 of Table A5
*-----------------------------------------
ivreghdfe lnso2  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation)   Productivity Tariff lnKL , a(indc year) cluster(prov_c)

ivreghdfe lndust  (Export Abatement_dust= tariff_prod ventilation_prod  ventilation)  Productivity Tariff lnKL if lndust<ub, a(indc  year) cluster(prov_c)
 /*
* compute R2
predict y_hat, xb
egen y_bar=mean(lndust_d)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lndust_d-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
*/

*------------------------------------------------------------------------------------

use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp2",clear
rename exp_dummy2 Export
rename so2_new1_d Abatement_so2
rename dust_new1_d Abatement_dust
rename tfp_acf_new_d Productivity
rename lntariff_d Tariff
rename lnkl_d lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod



replace Export= Export*1 if year==1999
replace Export= Export*1.3255 if year==2000
replace Export= Export*1.3882 if year==2001
replace Export= Export*1.6325 if year==2002
replace Export= Export*1.5373 if year==2003
replace Export= Export*1.3255 if year==2004
replace Export= Export*1.7373 if year==2005



replace Export= Export*1 if year==1999
replace Export= Export*1.3255 if year==2000
replace Export= Export*1.3882 if year==2001
replace Export= Export*1.6325 if year==2002
replace Export= Export*1.5373 if year==2003
replace Export= Export*1.3255 if year==2004
replace Export= Export*1.7373 if year==2005

*---------------------------------------
* 5.4 columns 4 and 8 of Table A5
*-----------------------------------------
ivreghdfe lnso2_d  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod)   Productivity Tariff lnKL , a(cic prov year ownership )  cluster(prov_c)

ivreghdfe lndust_d  (Export Abatement_dust= ventilation ventilation_prod tariff_prod)  Productivity Tariff lnKL, a(cic prov year ownership ) cluster(prov_c)
***************************************************************************************************************************












************************************     Table A6    *******************************************
************************************     Table A6    *******************************************
************************************     Table A6    *******************************************


  *---------------------------------------------------------------------------------
* For Columns 1-2 and 5-6: control for province, year, ownership and ownership FE
*---------------------------------------------------------------------------------- 

 
 
use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename TFP1_l Productivity_l
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod



*---------------------------------------
* 6.1 columns 1-2 of Table A6
*-----------------------------------------
ivreghdfe lnso2  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation)   Productivity_l Tariff, a(cic prov year ownership) cluster (prov_c)

ivreghdfe lnso2  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation)   Productivity_l Tariff lnKL lnso2_ini, a(cic prov year ownership) cluster (prov_c)



*---------------------------------------
* 6.2 columns 5-6 of Table A6
*-----------------------------------------
ivreghdfe lndust  (Export Abatement_dust=  tariff_prod ventilation_prod  ventilation)   Productivity_l Tariff  , a(cic prov year ownership) cluster (prov_c)

ivreghdfe lndust  (Export Abatement_dust=  tariff_prod ventilation_prod  ventilation)   Productivity_l Tariff lnKL lndust_ini , a(cic prov year ownership) cluster (prov_c)

 
 
 
/*
* compute R2
predict y_hat, xb
egen y_bar=mean(lndust)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lndust-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
*/
 
 

****************************************************************************

*---------------------------------------------------------------------------------
* For Columns 3-4 and 7-8: control for firm and year FE and first-difference 
*----------------------------------------------------------------------------------

use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp2",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename TFP_lag Productivity_l
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod


 capture drop ub
 egen ub=pctile(lndust),p(97)
 
 

*---------------------------------------
* 6.3 columns 3 and 7 of Table A6
*-----------------------------------------
ivreghdfe lnso2  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation)   Productivity_l Tariff lnKL , a(indc year) cluster(prov_c) first

 ivreghdfe lndust  (Export Abatement_dust= tariff_prod ventilation_prod  ventilation)  Productivity_l Tariff lnKL if lndust<ub, a(indc  year) cluster(prov_c)
 
 
 /*
* compute R2
predict y_hat, xb
egen y_bar=mean(lndust_d)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lndust_d-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
*/
 
*------------------------------------------------------------------------------------

use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp2",clear

rename exp_dummy2 Export
rename so2_new1_d Abatement_so2
rename dust_new1 Abatement_dust
*rename TFP_d_l Productivity
rename  TFP_d_l Productivity
rename lntariff_d Tariff
rename lnkl_d lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod



*---------------------------------------
* 6.4 columns 4 and 8 of Table A6
*-----------------------------------------
ivreghdfe lnso2_d  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod)   Productivity Tariff lnKL , a(cic prov year ownership )  cluster(prov_c)

ivreghdfe lndust_d  (Export Abatement_dust= ventilation ventilation_prod tariff_prod)  Productivity Tariff lnKL, a(cic prov year ownership ) cluster(prov_c)
***************************************************************************************************************************












************************************     Table A7    *******************************************
************************************     Table A7    *******************************************
************************************     Table A7    *******************************************


*---------------------------------------------------------------------------------
* For Columns 1-2 and 5-6: control for province, year, ownership and ownership FE
*---------------------------------------------------------------------------------- 

use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new2 Abatement_dust
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod


*---------------------------------------
* 7.1 columns 1-2 of Table A7
*-----------------------------------------
ivreghdfe lnso2  (Export Abatement_so2  exp_tfp abt_so2_exp= tariff_prod ventilation_prod ventilation IV1 IV2) Productivity Tariff, a(cic prov year ownership) cluster (prov_c)



ivreghdfe lnso2  (Export Abatement_so2 exp_tfp abt_so2_exp= tariff_prod ventilation_prod   ventilation IV1 IV2)   Productivity Tariff lnKL lnso2_ini, a(cic prov year ownership) cluster (prov_c)


*---------------------------------------
* 7.2 columns 1-2 of Table A7
*-----------------------------------------
ivreghdfe lndust  (Export Abatement_dust exp_tfp abt_dust_exp=  tariff_prod ventilation_prod  ventilation IV1 IV2)   Productivity Tariff  , a(cic prov year ownership) cluster (prov_c)

ivreghdfe lndust  (Export Abatement_dust exp_tfp abt_dust_exp=  tariff_prod ventilation_prod   ventilation IV1 IV2)   Productivity Tariff lnKL lndust_ini , a(cic prov year ownership) cluster (prov_c)




/*
* compute R2
predict y_hat, xb
egen y_bar=mean(lnso2)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lnso2-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
*/
 **********************************************************************************************************
 
 
*---------------------------------------------------------------------------------
* For Columns 3-4 and 7-8: control for firm and year FE and first-difference 
*----------------------------------------------------------------------------------

use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp2",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod


 capture drop ub
 egen ub=pctile(lndust),p(97)

 
 *---------------------------------------
* 7.3 columns 3 and 7 of Table A7
*-----------------------------------------
ivreghdfe lnso2  (Export Abatement_so2 exp_tfp abt_so2_exp= tariff_prod ventilation_prod  ventilation IV1 IV2)  ///
 Productivity Tariff lnKL , a(indc year) cluster (prov_c)
 
 
 
 
 

ivreghdfe lndust  (Export Abatement_dust exp_tfp abt_dust_exp= tariff_prod ventilation_prod ventilation  IV1 IV2)  ///
 Productivity Tariff lnKL , a(indc year) cluster (prov_c)
 
 
 
 /*
* compute R2
predict y_hat, xb
egen y_bar=mean(lnso2_d)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lnso2_d-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
*/
 ***********************************************

use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp2",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new_d Productivity
rename lntariff_d Tariff
rename lnkl_d lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod


*---------------------------------------
* 7.4 columns 4 and 8 of Table A7
*-----------------------------------------
ivreghdfe lnso2_d  (Export Abatement_so2 exp_tfp abt_so2_exp=  tariff_prod ventilation_prod  ventilation IV1 IV2 )   ///
Productivity Tariff lnKL , a(cic prov year ownership )  cluster (prov_c)




ivreghdfe lndust_d  (Export Abatement_dust exp_tfp abt_dust_exp=  tariff_prod ventilation_prod ventilation  IV1 IV2) ///
  Productivity Tariff lnKL , a(cic prov year ownership ) cluster (prov_c)



  
  
  
  
  
  
  
  
  
  
  
  
  
  





************************************     Table A8    *******************************************
************************************     Table A8    *******************************************
************************************     Table A8    *******************************************


*---------------------------------------------------------------------------------
* For Columns 1-2 and 5-6: control for province, year, ownership and ownership FE
*---------------------------------------------------------------------------------- 


use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod

capture drop ub_dust
egen ub_so2=pctile(lnso2), p(97)
egen ub_dust=pctile(lndust),p(97)




*---------------------------------------
* 8.1 columns 1 and 2 of Table A8
*-----------------------------------------
ivreghdfe lnso2  (Export Abatement_so2=   ventilation ventilation_prod tariff_prod) lnso2_lag  Productivity Tariff ,   a(cic prov year ownership) cluster (prov_c)  

ivreghdfe lnso2  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod) lnso2_lag  Productivity Tariff lnKL lnso2_ini ,   a(cic prov year ownership) cluster (prov_c) 

*---------------------------------------
* 8.2 columns 5 and 6 of Table A8
*-----------------------------------------
* for dust (column 5 and 6)
ivreghdfe lndust  (Export Abatement_dust=   ventilation ventilation_prod tariff_prod) lndust_lag  Productivity Tariff , a(cic prov year ownership) cluster (prov_c) 

ivreghdfe lndust  (Export Abatement_dust=   ventilation ventilation_prod tariff_prod) lndust_lag  Productivity Tariff lnKL lndust_ini , a(cic prov year ownership) cluster (prov_c) 

/*
* compute R2
predict y_hat, xb
egen y_bar=mean(lndust)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lndust-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
*/

*********************************************************
*---------------------------------------------------------------------------------
* For Columns 3-4 and 7-8: control for firm and year FE and first-difference 
*----------------------------------------------------------------------------------

use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp2",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod


 capture drop ub
 egen ub=pctile(lndust),p(97)
 
 *---------------------------------------
* 8.3 columns 3 and 7 of Table A8
*-----------------------------------------
  ivreghdfe lnso2  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation)  ///
lnso2_lag Productivity Tariff lnKL , a(indc year) cluster(prov_c)


 
 ivreghdfe lndust  (Export Abatement_dust= tariff_prod ventilation_prod  ventilation)  ///
lndust_lag Productivity Tariff lnKL if lndust<ub, a(indc  year)  cluster(prov_c)





 

/*
* compute R2
predict y_hat, xb
egen y_bar=mean(lndust_d)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lndust_d-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
*/


****************************************************************************************************




 
use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp2",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new_d Productivity
rename lntariff_d Tariff
rename lnkl_d lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod

capture drop ub_dust
egen ub_so2=pctile(lnso2), p(95)
egen ub_dust=pctile(lndust),p(95)
keep if year!=2004
*---------------------------------------
* 8.4 columns 4 and 8 of Table A8
*-----------------------------------------
ivreghdfe lnso2_d  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod) lnso2_lag Productivity Tariff lnKL , a(cic prov year ownership )  cluster(prov_c)


ivreghdfe lndust_d  (Export Abatement_dust=  ventilation ventilation_prod tariff_prod) lndust_lag Productivity Tariff lnKL, a(cic prov year ownership  )  cluster(prov_c)


















************************************     Table A9    *******************************************
************************************     Table A9    *******************************************
************************************     Table A9    *******************************************


*---------------------------------------------------------------------------------
* For Columns 1-2 and 5-6: control for province, year, ownership and ownership FE
*---------------------------------------------------------------------------------- 

 
 use "D:\Nanjing\2019\pollution2\submission\files for submission\data\balance_sample",clear


rename exp_dummy2 Export
rename so2_new1 Abatement_so2
*rename dust_new2 Abatement_dust
*rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod

capture drop ub_dust
egen ub_so2=pctile(lnso2), p(97)
egen ub_dust=pctile(lndust),p(97)




*---------------------------------------
* 9.1 columns 1 and 2 of Table A9
*-----------------------------------------
ivreghdfe lnso2  (Export Abatement_so2=   ventilation ventilation_prod tariff_prod)   Productivity Tariff ,   a(cic prov year ownership) cluster (prov_c)  

ivreghdfe lnso2  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod)  Productivity Tariff lnKL lnso2_ini  ,   a(cic prov year ownership) cluster (prov_c) 

*---------------------------------------
* 9.2 columns 5 and 6 of Table A9
*-----------------------------------------
ivreghdfe lndust  (Export Abatement_dust=   ventilation ventilation_prod tariff_prod)  Productivity Tariff  , a(cic prov year ownership) cluster (prov_c) 

ivreghdfe lndust  (Export Abatement_dust=   ventilation ventilation_prod tariff_prod)   Productivity Tariff lnKL lndust_ini, a(cic prov year ownership) cluster (prov_c) 

/*
* compute R2
predict y_hat, xb
egen y_bar=mean(lndust)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lndust-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
*/




*******************************************************************
*---------------------------------------------------------------------------------
* For Columns 3-4 and 7-8: control for firm and year FE and first-difference 
*----------------------------------------------------------------------------------

use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\balance_sample2",clear

rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod


*---------------------------------------
*9.3 columns 3 and 7 of Table A9
*-----------------------------------------
 ivreghdfe lnso2  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation)  ///
 Productivity Tariff lnKL , a(indc year) cluster(prov_c)


 
 ivreghdfe lndust  (Export Abatement_dust= tariff_prod ventilation_prod  ventilation)  ///
 Productivity Tariff lnKL , a(indc year) cluster(prov_c)
 /*
* compute R2
predict y_hat, xb
egen y_bar=mean(lnso2_d)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lnso2_d-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
*/

 
 *****************************************************************************************

 use "D:\Nanjing\2019\pollution2\submission\files for submission\data\balance_sample2",clear
capture drop Productivity
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
*rename dust_new2 Abatement_dust
rename tfp_acf_new_d Productivity
rename lntariff_d Tariff
rename lnkl_d lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod


*---------------------------------------
*9.4 columns 4 and 8 of Table A9
*-----------------------------------------

ivreghdfe lnso2_d  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod)  Productivity Tariff lnKL , a(cic prov year ownership )  cluster(prov_c)


ivreghdfe lndust_d  (Export Abatement_dust=  ventilation ventilation_prod tariff_prod)  Productivity Tariff lnKL, a(cic prov year ownership  )  cluster(prov_c)














************************************     Table A10  (A15)   *******************************************
************************************     Table A10  (A15)  *******************************************
************************************     Table A10  (A15)  *******************************************



 
use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod


*---------------------------------------------------------
*10.1 columns 1-3 of Table A10 (First stage for Table A15)
* first stage of so2 in Table A15
*---------------------------------------------------------
*SOE
ivreghdfe lnso2  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod  IV_so2 )   Productivity Tariff lnKL  lnso2_ini  if ownerships==1|ownerships==2, a(cic prov year ) cluster (prov_c) first
*Private
ivreghdfe lnso2  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod IV_so2  )   Productivity Tariff lnKL  lnso2_ini  if ownerships==3, a(cic prov year) cluster (prov_c) first
*Foreign 
ivreghdfe lnso2  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod IV_so2  )   Productivity Tariff lnKL  lnso2_ini  if ownerships==4|ownerships==5, a(cic prov year ) cluster (prov_c) first

 /*
* compute R2
predict y_hat, xb
egen y_bar=mean(lndust)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lndust-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
*/

*---------------------------------------
*10.1 columns 4-6 of Table A10
*-----------------------------------------
*SOE
ivreghdfe lndust  (Export Abatement_dust= ventilation ventilation_prod tariff_prod IV_dust )  Productivity Tariff lnKL lndust_ini if ownerships==1|ownerships==2, a(cic prov year ) cluster (prov_c) first
*Private
ivreghdfe lndust  (Export Abatement_dust= ventilation ventilation_prod tariff_prod IV_dust )  Productivity Tariff lnKL lndust_ini  if ownerships==3, a(cic prov year ) cluster (prov_c) first
*Foreign 
ivreghdfe lndust  (Export Abatement_dust= ventilation ventilation_prod tariff_prod IV_dust )  Productivity Tariff lnKL lndust_ini if ownerships==4|ownerships==5, a(cic prov year ) cluster (prov_c) first














************************************     Table A11  (A16)   *******************************************
************************************     Table A11  (A16)  *******************************************
************************************     Table A11  (A16)  *******************************************


use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp",clear
rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod



capture drop coast
gen coast=0
replace coast=1 if prov==51|prov==21|prov==13|prov==11|prov==22|prov==37|prov==32|prov==22|prov==33|prov==35|prov==44|prov==45|prov==46 /*coast=1 if a province is a coastal province*/
capture drop m_ventilation
gen m_ventilation=7.4907121658325195



*-----------------------------------------------------------
*11.1 columns 1-4 of Table A11 (First Stage for Table A16)
*----------------------------------------------------------
* Costal
ivreghdfe lnso2  (Export Abatement_so2= ventilation ventilation_prod tariff_prod)   Productivity Tariff lnKL  lnso2_ini lnso2_ini  if coast==1, a(cic prov year ownership) cluster (prov_c) first
* non-Coastal
ivreghdfe lnso2  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod)   Productivity Tariff lnKL  lnso2_ini  if coast==0, a(cic prov year ownership ) cluster (prov_c) first
* High-Mix
ivreghdfe lnso2  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod)   Productivity Tariff lnKL  lnso2_ini  if ventilation> m_ventilation, a(cic prov year ownership) cluster (prov_c) first
* Low-Mix
ivreghdfe lnso2  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod)   Productivity Tariff lnKL  lnso2_ini if ventilation<= m_ventilation, a(cic prov year ownership ) cluster (prov_c) first



 /*
* compute R2
predict y_hat, xb
egen y_bar=mean(lnso2)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lnso2-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
*/
*---------------------------------------------------------
*11.2 columns 5-8 of Table A11 (First Stage for Table A16)
*----------------------------------------------------------
* Coastal
ivreghdfe lndust  (Export Abatement_dust= ventilation ventilation_prod tariff_prod)  Productivity Tariff lnKL lndust_ini if coast==1, a(cic prov year ownership )  cluster (prov_c) first
* Non-Coastal
ivreghdfe lndust  (Export Abatement_dust= ventilation ventilation_prod tariff_prod)  Productivity Tariff lnKL lndust_ini if coast==0, a(cic prov year ownership )  cluster (prov_c) first

* High-Mix
ivreghdfe lndust   (Export Abatement_dust= ventilation ventilation_prod tariff_prod)  Productivity Tariff lnKL lndust_ini if ventilation>=  m_ventilation, a(cic prov year ownership )  cluster (prov_c) first
* Low-Mix
ivreghdfe lndust   (Export Abatement_dust= ventilation ventilation_prod tariff_prod)  Productivity Tariff lnKL lndust_ini if ventilation<  m_ventilation, a(cic prov year ownership )  cluster (prov_c) first












************************************     Table A12 (A16)  *******************************************
************************************     Table A12 (A16) *******************************************
************************************     Table A12 (A16) *******************************************






 
use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_comp",clear

rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename tfp_acf_new Productivity
rename lntariff Tariff
rename lnkl_lag lnKL
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod

*------------------------------------------------------------
*12.1: columns 1-3 of table A12 (First Stage for Table A16)
*-----------------------------------------------------------
ivreghdfe lnso2  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod)   Productivity Tariff lnKL  lnso2_ini if switch==1, a(cic prov year ownership) cluster (prov_c) first


ivreghdfe lnso2  (Export Abatement_so2=  ventilation ventilation_prod tariff_prod)   Productivity Tariff lnKL  lnso2_ini, a(cic_year prov  owner_year) cluster (prov_c) first

ivreghdfe lnso2  (Export Abatement_so2=  ventilation_prod tariff_prod  )   Productivity Tariff lnKL  lnso2_ini, a(cic_year prov_year  owner_year) cluster (prov_c) first


 /*
* compute R2
predict y_hat, xb
egen y_bar=mean(lndust)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lndust-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
*/
*-----------------------------------------------------------
*12.2: columns 4-6 of table A12 (First Stage for Table A16)
*------------------------------------------------------------
ivreghdfe lndust   (Export Abatement_dust= ventilation ventilation_prod tariff_prod dust_new2)  Productivity Tariff lnKL lndust_ini if  switch==1, a(cic prov year ownership) cluster (prov_c) first




ivreghdfe lndust   (Export Abatement_dust= ventilation ventilation_prod tariff_prod)  Productivity Tariff lnKL lndust_ini, a(cic_year prov  owner_year) cluster (prov_c)  first



ivreghdfe lndust   (Export Abatement_dust= ventilation_prod tariff_prod  )  Productivity Tariff lnKL lndust_ini , a(cic_year prov_year  owner_year) cluster (prov_c)  first













